package com.zxcrm.web.controller.zxcrm;

import com.zxcrm.common.annotation.Log;
import com.zxcrm.common.core.controller.BaseController;
import com.zxcrm.common.core.domain.AjaxResult;
import com.zxcrm.common.core.page.TableDataInfo;
import com.zxcrm.common.enums.BusinessType;
import com.zxcrm.common.utils.poi.ExcelUtil;
import com.zxcrm.zxcrm.domain.ZxcrmEvaluate;
import com.zxcrm.zxcrm.service.IZxcrmEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 评价Controller
 * 
 * @author xu
 * @date 2025-07-11
 */
@RestController
@RequestMapping("/zxcrm/evaluate")
public class ZxcrmEvaluateController extends BaseController
{
    @Autowired
    private IZxcrmEvaluateService zxcrmEvaluateService;

    /**
     * 查询评价列表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:evaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxcrmEvaluate zxcrmEvaluate)
    {
        startPage();
        List<ZxcrmEvaluate> list = zxcrmEvaluateService.selectZxcrmEvaluateList(zxcrmEvaluate);
        return getDataTable(list);
    }

    /**
     * 查询评价列表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:evaluate:list')")
    @GetMapping("/listAll")
    public AjaxResult lilistAllst(ZxcrmEvaluate zxcrmEvaluate)
    {
        List<ZxcrmEvaluate> list = zxcrmEvaluateService.selectZxcrmEvaluateList(zxcrmEvaluate);
        return AjaxResult.success(list);
    }

    /**
     * 导出评价列表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:evaluate:export')")
    @Log(title = "评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxcrmEvaluate zxcrmEvaluate)
    {
        List<ZxcrmEvaluate> list = zxcrmEvaluateService.selectZxcrmEvaluateList(zxcrmEvaluate);
        ExcelUtil<ZxcrmEvaluate> util = new ExcelUtil<ZxcrmEvaluate>(ZxcrmEvaluate.class);
        util.exportExcel(response, list, "评价数据");
    }

    /**
     * 获取评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:evaluate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zxcrmEvaluateService.selectZxcrmEvaluateById(id));
    }

    /**
     * 新增评价
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:evaluate:add')")
    @Log(title = "评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxcrmEvaluate zxcrmEvaluate)
    {
        return toAjax(zxcrmEvaluateService.insertZxcrmEvaluate(zxcrmEvaluate));
    }

    /**
     * 修改评价
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:evaluate:edit')")
    @Log(title = "评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZxcrmEvaluate zxcrmEvaluate)
    {
        return toAjax(zxcrmEvaluateService.updateZxcrmEvaluate(zxcrmEvaluate));
    }

    /**
     * 删除评价
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:evaluate:remove')")
    @Log(title = "评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zxcrmEvaluateService.deleteZxcrmEvaluateByIds(ids));
    }
}
